home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / bcfamily / source / qfilei.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-12  |  1.6 KB  |  62 lines

  1. //
  2. //      *******************************************************************
  3. //        JdeBP C++ Library Routines          General Public Licence v1.00
  4. //            Copyright (c) 1991,1992     Jonathan de Boyne Pollard
  5. //      *******************************************************************
  6. //
  7. // Part of FamAPI.LIB
  8. //
  9.  
  10. #include "famapi.h"
  11. #include "dosdos.h"
  12.  
  13. //
  14. //    Query file's information
  15. //
  16. USHORT _APICALL
  17. DosQFileInfo    ( unsigned short FileHandle,
  18.                   unsigned short InfoLevel,
  19.                   DOSFILESTATUS far *PtrFileStatus,
  20.                   unsigned short InfoBufferLength )
  21. {
  22.     FDATE date ;
  23.     FTIME time ;
  24.     USHORT err ;
  25.  
  26.     if (InfoLevel != 1) return ERROR_INVALID_FUNCTION ;
  27.  
  28.     if (InfoBufferLength < sizeof(DOSFILESTATUS))
  29.         return ERROR_BUFFER_OVERFLOW ;
  30.  
  31.     err = DosDosQFileTime (FileHandle, (USHORT far *)&date, (USHORT far *)&time) ;
  32.  
  33.     if (err) return err ;
  34.  
  35.     PtrFileStatus->fdateCreation =
  36.     PtrFileStatus->fdateLastAccess =
  37.     PtrFileStatus->fdateLastWrite = date ;
  38.     PtrFileStatus->ftimeCreation =
  39.     PtrFileStatus->ftimeLastAccess =
  40.     PtrFileStatus->ftimeLastWrite = time ;
  41.  
  42.     long oldpos ;
  43.  
  44.     err = DosChgFilePtr(FileHandle, 0L, 1, &oldpos) ;        // SEEK_CUR
  45.  
  46.     if (err) return err ;
  47.  
  48.     DosChgFilePtr(FileHandle, 0L, 2,
  49.                     (long far *)&PtrFileStatus->cbFile) ;    // SEEK_END
  50.     DosChgFilePtr(FileHandle, oldpos, 0, &oldpos) ;            // SEEK_SET
  51.  
  52.     // Round up to 4K multiple
  53.     PtrFileStatus->cbFileAlloc = (PtrFileStatus->cbFile + 0x0FFF) & ~0x0FFF ;
  54.  
  55.     //
  56.     // We cannot obtain this under DOS, so make a reasonable assumption.
  57.     //
  58.     PtrFileStatus->attrFile = _A_NORMAL ;
  59.  
  60.     return NO_ERROR ;
  61. }
  62.